<% include ../common/header.html %>

<div class="container bread hidden-xs">
    <a class="btn btn-default" href="/blog">返回首页</a>
    <p>目前位置: <a href="/blog">EUX博客</a>\博文</p>
</div>

<div class="container blog-container">
    <div class="row">
        <article class="col-lg-9 col-sm-8">
            <div class="blog-article" data-id="<%= article['_id'] %>">
                <header class="blog-header">
                    <div class="pic"><a href="/blog/user/<%= article.uid %>"><img width="64" src="/dist/img/icon/<%= article.usericon %>" alt=""></a></div>
                    <div class="title">
                        <a href="#"><h2><%= article.title %></h2></a>
                        <p>
                            <span><%= article.userdev %> <%= article.username %></span>
                            <span><%= article.date %></span>
                            <span><%= article.classify %></span>
                            <span class="hidden-xs"><i class="eux-icon eux-icon-eye"></i><%= article.visited %></span>
                            <span class="hidden-xs"><i class="eux-icon eux-icon-comment"></i><%= article.comments.length %></span>
                            <span class="hidden-xs"><i class="eux-icon eux-icon-good"></i><%= article.loved %></span>
                        </p>
                    </div>
                </header>
                <div class="content">
                    <%- article.content %>
                </div>
            </div>
            <% if (user) { %>
            <div class="blog-utils">
                <div class="good" id="thumb-up">
                    <div class="icon">
                        <a href="#"><span class="eux-icon eux-icon-good-lg <%= thumbed %>"></span></a>
                    </div>
                    <p><%= article.loved %></p>
                </div>
                <div class="love" id="collect">
                    <div class="icon">
                        <a href="#"><span class="eux-icon eux-icon-love-lg <%= collected %>"></span></a>
                    </div>
                    <p>收藏</p>
                </div>
                <% if (user['_id'] == article.uid) { %>
                <div class="delete hidden-xs">
                    <div class="icon">
                        <a id="article-delete" href="#">
                            <span class="eux-icon eux-icon-delete-lg"></span>
                            <p>删除</p>
                        </a>
                    </div>

                </div>
                <div class="edit hidden-xs">
                    <div class="icon">
                        <a href="/blog/edit?bid=<%= article['_id'] %>">
                            <span class="eux-icon eux-icon-edit-lg"></span>
                            <p>编辑</p>
                        </a>
                    </div>

                </div>
                <% } %>
            </div>
            <% } %>

            <% for (var comment of article.comments) { %>
            <div class="comment-item">
                <div class="comment-content">
                    <div class="clearfix">
                        <div class="user hidden-xs"><a href="/blog/user/<%= comment.uid %>"><img width="48" src="/dist/img/icon/<%= comment.usericon %>"></a></div>
                        <div class="comment">
                            <div><a href="/blog/user/<%= comment.uid %>"><%= comment.userdep %> <%= comment.username %>: </a><%= comment.content %></div>
                            <p><%= formatDate(comment.date) %></p>
                        </div>
                    </div>
                    <% if (user && comment.uid) { %><div class="reply-btn hidden-xs"><a class="comment-reply-btn" data-cid="<%= comment['_id'] %>" data-uid="<%= comment.uid %>" href="#">回复</a></div> <% } %>
                    <div class="reply-form" style="display: none;">
                        <form>
                            <div class="form-group">
                                <textarea name="comment" class="form-control" maxlength="256" required rows="10" placeholder="@<%= comment.username %>"></textarea>
                            </div>
                            <button type="submit" class="btn btn-default">评论</button>
                        </form>
                    </div>
                </div>
                <% if (comment.replyList.length) { %>
                <% for (var reply of comment.replyList) { %>
                <div class="comment-reply">
                    <div class="reply-item">
                        <a href="/blog/user/<%= reply.uid %>"><%= reply.userdep %> <%= reply.username %>: </a>
                        <span class="text-primary">@<%= reply.replyUserdep %> <%= reply.replyUsername %></span>
                        <span><%= reply.content %></span>
                        <% if (user) { %><a data-cid="<%= comment['_id'] %>" data-uid="<%= reply.uid %>" class="reply reply-reply-btn" href="#">回复</a> <% } %>
                    </div>
                    <div class="reply-form" style="display: none;">
                        <form>
                            <div class="form-group">
                                <textarea name="comment" class="form-control" rows="10" placeholder="@<%= reply.replyUserdep %> <%= reply.username %>"></textarea>
                            </div>
                            <button type="submit" class="btn btn-default">评论</button>
                        </form>
                    </div>
                </div>
                <% } %>
                <% } %>
            </div>
            <% } %>

            <div class="comment-form" data-id="<%= article.uid %>">
                <form>
                    <% if (!user) { %>
                    <div class="form-group">
                        <input name="username" type="text" class="form-control" placeholder="姓名" required>
                    </div>
                    <div class="form-group">
                        <input name="useremail" type="email" class="form-control" placeholder="邮箱" required>
                    </div>
                    <% } %>
                    <div class="form-group">
                        <textarea name="comment" class="form-control" rows="10" maxlength="256" required placeholder="请输入评论, 最多256个字"></textarea>
                    </div>
                    <button type="submit" class="btn btn-default">评论</button>
                </form>
            </div>
        </article>
        <% include aside.html %>
    </div>
</div>

<script src="/dist/js/blog/detail.min.js"></script>
<% include ../common/common_footer.html %>
<% include ../common/footer.html %>
